using Digitalmes.Domain.Entities.Mes.Processes;

namespace Digitalmes.Application.Mes.Processes.Operations.Commands;

/// <summary>
/// 工序删除命令。
/// </summary>
/// <param name="OpId"></param>
public record DeleteOperationCommand(long OpId) : IRequest<IResult<bool>>;

internal sealed class DeleteOperationCommandHandler(IRepository<ProcOperation> repo) : IRequestHandler<DeleteOperationCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteOperationCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.OpId, cancellationToken);
        return Result.From(ok);
    }
}
